package com.sjq.controller;

import com.sjq.mapper.UserMapper;
import com.sjq.model.common.BaseResult;
import com.sjq.model.common.ResponseBean;
import com.sjq.service.IPaperService;
import com.sjq.util.UserUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

/**
 * @author: sjq
 * @create: 2022-04-16
 **/
@Api(tags = "专家")
@RestController
@RequestMapping("/expert")
public class ExpertController {

    @Autowired
    private IPaperService paperService;

    @Autowired
    private UserUtil userUtil;

    @Autowired
    private UserMapper userMapper;
    /**
     * 修改状态
     */
    @RequiresAuthentication
    @ApiOperation("审核稿件")
    @GetMapping("edit/{ids}")
    public BaseResult edit(@PathVariable Long[] ids, @RequestHeader String Authorization)
    {
        if(paperService.updatePaperExpertStatus(ids)>0)
        {
            paperService.insertZhengGao(userUtil.getUserId(),ids);
            return BaseResult.success("修改成功");
        }
        else
            return BaseResult.error();
    }

    @ApiOperation("专家筛查")
    @GetMapping("/{classification}")
    public BaseResult getExpert(@PathVariable String classification)
    {
        return  BaseResult.success( "筛查成功", userMapper.getExpert(classification));
    }
    @ApiOperation("全部专家")
    @GetMapping
    public BaseResult getExpertAll()
    {
        return  BaseResult.success( "成功获取", userMapper.getExpertAll());
    }
}
